package com.leetcode.partition12;

/**
 * @author `RKC`
 * @date 2022/2/13 10:01
 */
public class LC1189气球的最大数量 {

    public int maxNumberOfBalloons(String text) {
        String s = "balloon";
        int[] cnt = new int[26];
        for (int i = 0; i < text.length(); i++) cnt[text.charAt(i) - 'a']++;
        int ans = 0x3f3f3f3f;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int t = cnt[c - 'a'];
            if (c == 'o' || c == 'l') t /= 2;
            ans = Math.min(ans, t);
        }
        return ans;
    }
}
